package com.ldu.exam.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ldu.exam.model.NoticeModel;
import com.ldu.exam.service.NoticeService;


@RequestMapping(value="/notice")
@RestController
public class NoticeController 
{
	@Autowired NoticeService service;
	
	@GetMapping()
	public Page<NoticeModel> findAll(@RequestParam String isRead,@RequestParam String accountId,@PageableDefault(size=20) Pageable page)
	{
		return this.service.findAll(isRead,accountId,page);
	}
	
	@PostMapping()
	public Object add(@RequestBody NoticeModel model) 
	{
		return null;
	}
	
	@PutMapping(value="/{id}")
	public Object update(@PathVariable String id , @RequestBody NoticeModel model)
	{
		return this.service.update(id, model);
	}
	
	@PutMapping(value="/onRead")
	public Object onRead(@RequestParam String id, @RequestParam String isRead)
	{
		return this.service.onRead(id, isRead);
	}
}
